
N = 1000000
isp = [1 for i in xrange(N)]

isp[0] = isp[1] = 0

for i in xrange(N):
    if isp[i]:
        for j in xrange(i + i, N, i):
            isp[j] = 0

ans = 0
count = 0
for a in xrange(-999, 999):
    for b in xrange(-999, 999):
        t = 0
        n = 0
        while 1:
            p = n * n + a * n + b
            if p < 0:
                break
            if p > N:
                print p
                print 'fuck'
            if not isp[p]:
                break
            t += 1
            n += 1
        if count < t:
            count = t
            ans = a * b

print count, ans

